/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;
import java.util.List;

/**
 * <p>Project: javase2203 - Arr7
 * <p>Powered by webrx On 2022-07-12 15:48:29
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Arr7 {
    public static void main(String[] args) {
        //int Integer
        //int 基本类型 Integer 对象类型是int包装类

        //装箱操作
        //Integer a = 30;

        //拆箱操作
        //int b = a;



        //内置排序
        Integer[] n = {1, 10, 5, 2, 70, 9, 20, 35};
        System.out.println("排序前：" + Arrays.toString(n));
        //默认是升序
        Arrays.sort(n);
        System.out.println("默认是升序后：" + Arrays.toString(n));

        //升序
        Arrays.sort(n, (a, b) -> a - b);
        System.out.println("升序后：" + Arrays.toString(n));

        //降序
        Arrays.sort(n, (a, b) -> b - a);
        System.out.println("降序后：" + Arrays.toString(n));

        //乱序
        Arrays.sort(n, (x, y) -> Math.random() > .5 ? 1 : -1);
        System.out.println("乱序后：" + Arrays.toString(n));
    }
}
